<?php 

class videoController extends appController
{
	public function video_list()
	{
		if(!$_SESSION['wxid'])
		{
			$this->check_member();
		}
		$this->assign_global();
		$project = Model('video');
		$info = $project->get_video_list();
		$this->assign('list',$info);
		$this->display('list.html');
	}
	
	public function video()
	{
		if(!$_SESSION['wxid'])
		{
			//$this->check_member();
		}
		$this->assign_global();
		$id = intval($_GET['id']);
		$project = Model('video');
		$info = $project->get_video($id);
		$this->assign('info',$info);
		$info = $project->get_comment($id);
		$this->assign('comment',$info);
		$this->display('video.html');
	}
	
	public function comment()
	{
		$result = array('error'=>1,'content'=>'请先登陆'); 
		$video = Model('video');
		
 		$_SESSION['wxid'] =2;
 		$str_num = hy_strlen($_POST['content']);
 		$info['video_id'] = intval($_POST['video_id']);
 		if($_SESSION['vc_num_'.$info['video_id']]>3)
 		{
 			$result['content'] = '你提交得太频繁了';
 			die(json_encode($result));
 		}
 	
 		if($str_num>30)
 		{
 			
 			$result['content'] = '评论内容请不要大于30个字喔'.$_SESSION['vc_num_'.$info['video_id']];
 			die(json_encode($result));
 		}
 		
 		
 		
		if($_SESSION['wxid'])
		{
			$info['wxid'] = $_SESSION['wxid'];
			$info['content'] = strip_tags($_POST['content']);
			$info['add_time'] = $_SERVER['REQUEST_TIME'];
			
			$result['error'] = 0;
			$result['content'] = '评论成功，请等待审核';
			$video->insert($info,'video_comment');
			$_SESSION['vc_num_'.$info['video_id']] = isset($_SESSION['vc_num_'.$info['video_id']]) ?$_SESSION['vc_num_'.$info['video_id']]+1:0;
		}
		die(json_encode($result));
	}
}

?>
